package com.hncu.Test;

import java.util.Scanner;

public class Demo6 {
    /*String[]split(String regex):以括号里的字符串作为规则分割字符串，
      分割的内容存到字符串数组中，并且返回数组*/
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();//获取字符串
        String[] srr = s.split(",");
        Test6Student student = new Test6Student();//无参构造
        //设置参数
        student.setName(srr[0]);
        student.setAge(srr[1]);
        System.out.println(student.getName());
        System.out.println(student.getAge());
        System.out.println("----------------");
        Test6Student stu = new Test6Student(srr);//参数构造
        System.out.println(stu.getName());
        System.out.println(stu.getAge());
    }
}
